home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / strlib.zip / STRCHR.C < prev    next >
Text File  |  1993-01-04  |  1KB  |  29 lines

  1.  
  2. /*  File   : strchr.c
  3.     Author : Richard A. O'Keefe.
  4.     Updated: 20 April 1984
  5.     Defines: strchr(), index()
  6.  
  7.     strchr(s, c) returns a pointer to the  first  place  in  s  where  c
  8.     occurs,  or  NullS if c does not occur in s. This function is called
  9.     index in V7 and 4.?bsd systems; while not ideal the name is  clearer
  10.     than  strchr,  so index remains in strings.h as a macro.  NB: strchr
  11.     looks for single characters,  not for sets or strings.   To find the
  12.     NUL character which closes s, use strchr(s, '\0') or strend(s).  The
  13.     parameter 'c' is declared 'int' so it will go in a register; if your
  14.     C compiler is happy with register _char_ change it to that.
  15. */
  16.  
  17. #include "strings.h"
  18.  
  19. char *strchr(s, c)
  20.     register _char_ *s;
  21.     register int c;
  22.     {
  23.         for (;;) {
  24.             if (*s == c) return s;
  25.             if (!*s++) return NullS;
  26.         }
  27.     }
  28.  
  29.